package com.demo1.servlet; /**
 * @author wzm
 * @create 2023-11-07 16:06
 * project_name:web2310
 * @Description
 */

import com.demo1.dao.UserDao;
import com.demo1.entity.User;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.util.List;

@WebServlet("/serachServlet")
public class SerachServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("UTF-8");
        response.setContentType("text/html;charset=UTF-8");

        String likeName = request.getParameter("serach");

        List<User> list = new UserDao().selectByLikeName(likeName);
        System.out.println("list = " + list);
        response.getWriter().write(String.valueOf(list));
    }
}
